** Command codes to reproduce the results in "Disagreement and Deliberation: Evidence from Three Deliberative Mini-Publics"
** Authors: Kimmo Grönlund, Kaisa Herne, Kim Strandberg and Peter Söderlund
** Dataset: Deliberative Discussion on Nuclear Power 2006
** Source: Full dataset (.csa, .por) available via the Finnish Social Science Data Archive, http://urn.fi/urn:nbn:fi:fsd:T-FSD2355
** Note: The analyses below are based on a reduced version of the dataset available via the Finnish Social Science Data Archive


** Open Nuclear power file
use "...\Nuclear data.dta"

** Recode variables

* Recode - Attitudes toward nuclear power (scale 0 to 10)
recode v12t1 v13t1 v14t1 (1=4) (2=3) (3=2) (4=1)
recode v1t1 v2t1 v3t1 v4t1 v5t1 v6t1 v7t1 v8t1 v9t1 v10t1 v11t1 v12t1 v13t1 v14t1 v15t1 v16t1 v17t1 v18t1 v19t1 (1=0) (2=3.33) (3=6.66) (4=10)

* Identify missing values - Attitudes toward nuclear power (scale 0 to 10)
mvpatterns v1t1 v7t1 v11t1 v12t1 v13t1 v14t1 v15t1 v16t1
egen ind_missing = rowmiss(v1t1 v7t1 v11t1 v12t1 v13t1 v14t1 v15t1 v16t1)
egen meanv1t1 = mean(v1t1) 
egen meanv7t1 = mean(v7t1) 
egen meanv11t1 = mean(v11t1) 
egen meanv12t1 = mean(v12t1) 
egen meanv13t1 = mean(v13t1) 
egen meanv14t1 = mean(v14t1) 
egen meanv15t1 = mean(v15t1) 
egen meanv16t1 = mean(v16t1) 

* Replace missing values - Attitudes toward nuclear power (scale 0 to 10)
replace v1t1 = meanv1t1 if v1t1 == .
replace v7t1 = meanv7t1 if v7t1 == .
replace v11t1 = meanv11t1 if v11t1 == .
replace v12t1 = meanv12t1 if v12t1 == .
replace v13t1 = meanv13t1 if v13t1 == .
replace v14t1 = meanv14t1 if v14t1 == .
replace v15t1 = meanv15t1 if v15t1 == .
replace v16t1 = meanv16t1 if v16t1 == .

* Recode - Quality of deliberation
gen opinionchange1 = v94t4
gen opinionchange2 = v95t4
gen pleasantexperience = v96t4
gen moreknowledge = v97t4
gen morereadiness = v98t4
gen participatefuture = v99t4
gen moredeliberation = v103t4
gen active = v104t4
gen respect = v106t4
gen ownopinions = v107t4
recode opinionchange1 opinionchange2 moreknowledge morereadiness moredeliberation participatefuture pleasantexperience active respect ownopinions (1=0) (2=3.33) (3=6.66) (4=10)

* Identify missing values - Quality of deliberation (scale 0 to 10)
mvpatterns opinionchange1 opinionchange2 moreknowledge morereadiness moredeliberation participatefuture pleasantexperience active respect ownopinions
egen dep1_missing = rowmiss(moreknowledge morereadiness pleasantexperience participatefuture ownopinions)
egen meanopinionchange1 = mean(opinionchange1)
egen meanopinionchange2 = mean(opinionchange2)
egen meanmoreknowledge = mean(moreknowledge)
egen meanmorereadiness = mean(morereadiness)
egen meanmoredeliberation = mean(moredeliberation)
egen meanparticipatefuture = mean(participatefuture)
egen meanpleasantexperience = mean(pleasantexperience)
egen meanactive = mean(active)
egen meanrespect = mean(respect)
egen meanownopinions = mean(ownopinions)

* Replace missing values - Quality of deliberation (scale 1 to 10)
egen dep1_rowmean = rmean(moreknowledge morereadiness moredeliberation participatefuture pleasantexperience)
replace moreknowledge = meanmoreknowledge if moreknowledge == .
replace morereadiness = meanmorereadiness if morereadiness == .
replace moredeliberation = meanmoredeliberation if moredeliberation == .
replace participatefuture = meanparticipatefuture if participatefuture == .
replace pleasantexperience = meanpleasantexperience if pleasantexperience == .
replace opinionchange1 = meanopinionchange1 if opinionchange1 == .
replace opinionchange2 = meanopinionchange2 if opinionchange2 == .
replace active = meanactive if active == .
replace respect = meanrespect if respect == .
replace ownopinions = meanownopinions if ownopinions == .

** Factor analysis

* Factor analysis - Attitudes toward nuclear power (scale 0 to 10)
summ v1t1 v7t1 v11t1 v12t1 v13t1 v14t1 v15t1 v16t1
polychoric v1t1 v7t1 v11t1 v12t1 v13t1 v14t1 v15t1 v16t1
display r(sum_w)
global N = r(sum_w)
matrix r = r(R)
factormat r, n($N) factors(1) pcf

* Factor analysis - Quality of deliberation index (scale 0 to 10)
summ moreknowledge morereadiness moredeliberation participatefuture pleasantexperience
polychoric moreknowledge morereadiness moredeliberation participatefuture pleasantexperience
display r(sum_w)
global N = r(sum_w)
matrix r = r(R)
factormat r, n($N) factors(1) pcf

** Generate means and standard deviations

* Generate mean - Attitudes toward nuclear power (scale 1 to 10)
generate nuclear_mean = (v1t1 + v7t1 + v11t1 + v12t1 + v13t1 + v14t1 + v15t1 + v16t1) / 8

* Generate mean - Quality of deliberation (scale 0 to 10)
generate index_mean = (moreknowledge + morereadiness + pleasantexperience + participatefuture + ownopinions) / 5

* Standard deviation by group - Attitudes toward nuclear power (scale 1 to 10)
bys group: asrol nuclear_mean, stat(sd) xf(focal)
rename sd_nuclear_mean tabledisagreement
summ tabledisagreement
generate tabledisagreement_c = tabledisagreement - 2.7
generate tabledisagreement_c_squared = tabledisagreement_c * tabledisagreement_c

* Group mean centering - Attitudes toward nuclear power (scale 1 to 10)
bys group: asrol nuclear_mean, stat(mean) xf(focal)
generate dnuclear_mean = nuclear_mean - mean_nuclear_mean
generate dnuclear_mean_abs = abs(dnuclear_mean)
summ dnuclear_mean_abs
generate dnuclear_mean_abs_c = dnuclear_mean_abs - 2.4

** Empirical analyses

* Table 3 - Nuclear power - Descriptive statistics
preserve
collapse (mean) sdtabledisagreement=tabledisagreement (mean) meannuclear_mean=nuclear_mean, by(group)
sort sdtabledisagreement
tab sdtabledisagreement
sort meannuclear_mean
tab meannuclear_mean
restore

* Table 4 - Nuclear power - Mean and standard deviation - Attitudes toward nuclear power (scale 1 to 10)
tabstat index_mean, statistics(mean sd)

* Table 4 - Nuclear power - Cronbach's alpha - Quality of deliberation index (scale 0 to 10)
alpha moreknowledge morereadiness pleasantexperience participatefuture ownopinions

* Table 5 - Linear model - Adjusted R2 - OLS regressions without cluser-robust standard errors
regress index_mean c.tabledisagreement_c c.dnuclear_mean_abs_c i.treatment, 

* Table 5 - Curvilinear model - Adjusted R2 - OLS regressions without cluser-robust standard errors
regress index_mean c.tabledisagreement_c##c.tabledisagreement_c c.dnuclear_mean_abs_c##c.dnuclear_mean_abs_c i.treatment, 

* Table 5 - Linear model - Coefficients - OLS regression with cluser-robust standard errors
regress index_mean c.tabledisagreement_c c.dnuclear_mean_abs_c i.treatment, vce(cluster group)

* Table 5 - Curvilinear model - Coefficients - OLS regression with cluser-robust standard errors
regress index_mean c.tabledisagreement_c##c.tabledisagreement_c c.dnuclear_mean_abs_c##c.dnuclear_mean_abs_c i.treatment, vce(cluster group)

* Figure 1
regress index_mean c.tabledisagreement_c##c.tabledisagreement_c c.dnuclear_mean_abs_c##c.dnuclear_mean_abs_c i.treatment, vce(cluster group)
margins, at(tabledisagreement_c=(-1.03(0.01)1.82)) post coeflegend 
lincom (_b[1._at] - _b[225._at])
marginsplot, legend(title("", color(black) size(medium))) recast(line) recastci(rarea) plot1opts(lpattern(solid) lcolor(midblue%100) lwidth(thick)) ci1opts(lpattern(solid) color(midblue%30) lcolor(midblue%5) lwidth(thin)) ylabel(5(1)10, angle(90) nogrid glcolor(gs14) labsize(4) format(%9.0f)) ytitle("Process Satisfaction Index", size(5) height(6)) yscale(noline) xscale(noline) xlabel(-2.7 "0" -1.7 "1" -0.7 "2" 0.3 "3" 1.3 "4" 2.3 "5", labsize(4) format(%3.1f)) xtitle("Group-level Disagreement", size(5) height(6)) graphregion(fcolor(white) lcolor(white) lwidth(thick)) plotregion(fcolor(white) lcolor(black) lwidth(thin)) title("") subtitle("Deliberation on Nuclear Power", size(5) color(black)) xsize(8) ysize(8) 

* Figure 2
regress index_mean c.tabledisagreement_c##c.tabledisagreement_c c.dnuclear_mean_abs_c##c.dnuclear_mean_abs_c i.treatment, vce(cluster group)
margins, at(dnuclear_mean_abs_c=(-2.4(0.01)3.6)) coeflegend post
lincom (_b[1._at] - _b[62._at])
marginsplot, legend(title("", color(black) size(medium))) recast(line) recastci(rarea) plot1opts(lpattern(solid) lcolor(midblue%100) lwidth(thick)) ci1opts(lpattern(solid) color(midblue%30) lcolor(midblue%5) lwidth(thin)) ylabel(5(1)10, angle(90) nogrid glcolor(gs14) labsize(4) format(%9.0f)) ytitle("Process Satisfaction Index", size(5) height(6)) yscale(noline) xscale(noline) xlabel(-2.4 "0" -1.4 "1" -0.4 "2" 0.6 "3" 1.6 "4" 2.6 "5" 3.6 "6", labsize(4) format(%3.0f)) xtitle("Individual-level Disagreement", size(5) height(6)) graphregion(fcolor(white) lcolor(white) lwidth(thick)) plotregion(fcolor(white) lcolor(black) lwidth(thin)) title("") subtitle("Deliberation on Nuclear Power", size(5) color(black)) xsize(8) ysize(8) 

* Power analysis
power oneslope 0 -0.65, sdx(0.72) sdy(1.27) power(.8)
power oneslope 0 -0.65, sdx(0.72) sdy(1.27) power(.9)
power oneslope 0, n(135) sdx(0.72) sdy(1.27) power(.8)
power oneslope 0, n(135) sdx(0.72) sdy(1.27) power(.9)



